
package com.b2mining.integration.xml;

import java.util.*;

import org.jdom.Element;

import com.b2mining.integration.beans.MapperException;


/**
 * Clase que almacena los errores encontrados en el parseo o generacion de documentos CSV
 * @since (7/3/2003 10:35:26 AM)
 * @author Synopsis S.A. <BR>
 * Analista Programador: Miguel Lora G.,Janyn Roca
 * 						
 */
public class XMLMapperException extends MapperException {
	
	private String parent;
	
	/**
	 * Returns the parent.
	 * @return String
	 */
	public String getParent() {
		return parent;
	}
	/**
	 * Sets the parent.
	 * @param parent The parent to set
	 */
	public void setParent(Element parentXML) {
		parent = "";
		while (parentXML.getParent() != null) {
			int position = 0;
			// Obtaining the parent's name:
			String parentName = parentXML.getName();
			// Obtaining the parent's parent element:
			Element gparent = parentXML.getParent();
			if (gparent != null) {
				// Obtaining the list of siblings:
				List siblings = gparent.getChildren(parentName);
				// Obtaining the position of the parent:

				for (int i = 0; i < siblings.size(); i++) {
					if (siblings.get(i).equals(parentXML)) {
						position = i;
						parent =
							"(" + parentName + "," + position + ")" + parent;
						break;
					}
				}
			}
			parentXML = gparent;

		}
	}

	
	public XMLMapperException() {
	}
	public XMLMapperException(String s) {
		error=s;
		MapperException child = new MapperException();
		child.setElement("");
		child.setError(s);
		children.add(child);		
//		super(s);
	}
	
	
}